package handler

import (
	"github.com/gin-gonic/gin"
)

func WebSocketMiddleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		// 为每个请求创建一个唯一的连接ID
		connID := c.Request.Header.Get("Sec-WebSocket-Key")
		if conn, exists := getWSConnection(connID); exists {
			c.Set("wsConn", conn)
		}
		c.Next()
	}
} 